//
//  HomePageHouseModel.m
//  PersonalProjects
//
//  Created by lanou3g on 15/9/11.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "HomePageHouseModel.h"

@implementation HomePageHouseModel

- (instancetype)initWithDic:(NSDictionary *)infoDic {
    self = [super init];
    if (self) {
        _houseId = [self objectOrNilForKey:@"house_id" fromDictionary:infoDic];
        _title = [self objectOrNilForKey:@"title" fromDictionary:infoDic];
        _price = [self objectOrNilForKey:@"price" fromDictionary:infoDic];
        _longPrice = [self objectOrNilForKey:@"long_price" fromDictionary:infoDic];
        _middlePrice = [self objectOrNilForKey:@"middle_price" fromDictionary:infoDic];
        _shortPrice = [self objectOrNilForKey:@"short_price" fromDictionary:infoDic];
        _minNights = [self objectOrNilForKey:@"min_nights" fromDictionary:infoDic];
        _bedroomNum = [self objectOrNilForKey:@"bedroom_num" fromDictionary:infoDic];
        _roomNum = [self objectOrNilForKey:@"room_num" fromDictionary:infoDic];
        _washroomNum = [self objectOrNilForKey:@"washroom_num" fromDictionary:infoDic];
        _square = [self objectOrNilForKey:@"square" fromDictionary:infoDic];
        _personNum = [self objectOrNilForKey:@"person_num" fromDictionary:infoDic];
        _bedNum = [self objectOrNilForKey:@"bed_num" fromDictionary:infoDic];
        _districtId = [self objectOrNilForKey:@"district_id" fromDictionary:infoDic];
        _imgURLString = [self objectOrNilForKey:@"img_url" fromDictionary:infoDic];
        _houseType = [self objectOrNilForKey:@"house_type" fromDictionary:infoDic];
        _longitude = [self objectOrNilForKey:@"lng" fromDictionary:infoDic];
        _latitude = [self objectOrNilForKey:@"lat" fromDictionary:infoDic];
        _landmarkName = [self objectOrNilForKey:@"landmark_name" fromDictionary:infoDic];
        _specialPriceStatus = [[self objectOrNilForKey:@"special_price_status" fromDictionary:infoDic] boolValue];
        _specialPrice = [NSString stringWithFormat:@"%@",[self objectOrNilForKey:@"special_price" fromDictionary:infoDic]];
    }
    return self;
}

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}

@end
